package com.hitown.service.impl.dxhd;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hitown.dao.dxhd.DxhdJqMapper;
import com.hitown.model.dxhd.DxhdJq;
import com.hitown.service.dxhd.DxhdJqService;
import com.hitown.util.PageVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 警情数据信息 服务实现类
 * </p>
 *
 * @author menu
 * @since 2021-07-19
 */
@Service
public class DxhdJqServiceImpl extends ServiceImpl<DxhdJqMapper, DxhdJq> implements DxhdJqService {

    @Autowired
    private DxhdJqMapper dxhdJqMapper;

    @Override
    public PageVo<DxhdJq> myquery(Long current, Long limit, DxhdJq dxhdJq) {

        //初始化page
        Page<DxhdJq> page = new Page<>(current,limit);
        //设置条件
        QueryWrapper<DxhdJq> wrapper =new QueryWrapper<>();
        //eq是等于，ge是大于等于，gt是大于，le是小于等于，lt是小于，like是模糊查询
        if(!StringUtils.isEmpty(dxhdJq.getBjrXm())){
            wrapper.like("BJR_XM",dxhdJq.getBjrXm());
        }
        if(!StringUtils.isEmpty(dxhdJq.getBz())) {
            wrapper.eq("bz", dxhdJq.getBz());
        }

        //执行查询
        dxhdJqMapper.selectPage(page,wrapper);
        List<DxhdJq> list = page.getRecords();
        PageVo<DxhdJq> userVo =new PageVo();
        userVo.setSize(page.getSize());
        userVo.setTotal(page.getTotal());
        userVo.setCurrent(page.getCurrent());
        userVo.setUserList(list);

        return userVo;
    }

}
